<?php
	include_once '../../include/inc_session.php';
	
	if (isset($_GET['id']) && isset($_GET['idc']) && isset($_GET['typass']) && isset($_GET['sin'])) 
	{
		$oPaj = new Template(PATH_TEMPLATE.'tpl_synthese_sinistre.html');
		$oPaj->replace('nom_module', $oBloc->_MENU_NOM);
		$oPaj->replace('nom_fonction', $oFonction->_MENU_AFFICHE);
		$oPaj->replace('nom_liste', "Synthèse");
		
		$oPaj->replace('css_module', "../../sinistres/list.css");
		
	  		$idUser = $_SESSION["iduser"];
			$idPersonne = $_GET['id'];
	  		$sTypass = $_GET['typass'];
	  		$idContrat = $_GET['idc'];
	        $iSinistre = $_GET['sin'];
	  		
	  		$oContrat = new dataObject_contrat($idContrat);
	  	//	$EFFET_DATE = $oContrat->_DATE_EFFET;
	  		$EFFET_DATE=$oContrat->contrat_getDateEffet($idContrat);
	  	
	  		if($iSinistre != '')
	  		{
	  			$oSinistre = new dataObject_sinistre($iSinistre);
		  	  	$oJustificatif = new dataObject_justificatif($iSinistre);
				$aListJustif = $oJustificatif->justificatif_getListPieceManquante($iSinistre);
		  		if($oSinistre->_TYPE_SINISTRE == 'D')
		 			$sAutreCode = 'CIN';
		 		else $sAutreCode = 'CD';
		 		if((count($aListJustif) == 1) && ($aListJustif[0]['Code_condition_indemnisation']== $sAutreCode))
		 		{
		 			$aListJustif = array();
		 		}
		 		
				if(empty($aListJustif))
				{
					$oPaj->replace('checked','checked=checked');
					//on désactive aussi le bouton "pieces manquantes"
					$sUrlPiecesManquantes = "#";
				}
				else
				{
					$oPaj->replace('checked1','checked=checked');
					$sUrlPiecesManquantes = 'liste_pieces_manquantes.php?id='.$idPersonne.'&idc='.$idContrat.'&typass='.$sTypass.'&sin='.$iSinistre;
				}
	  		}
	  		else
	  		{
	  			$oPaj->replace('checked','');
	  			$oPaj->replace('checked1','checked=checked');
	  			$sUrlPiecesManquantes = "#";
	  		}
	
	
	$oPaj->replace('url_pieces_manquantes', $sUrlPiecesManquantes);
			
	if($_SESSION['idfonction']== dataObject_menu::FCT_SIN_COMPLEMENT_ID)
		$oPaj->replace('url_Retour', '../justificatif/index.php?id='.$idPersonne.'&idc='.$idContrat.'&typass='.$sTypass.'&sin='.$iSinistre);
	else $oPaj->replace('url_Retour', '../declaration/declarer_sinistre.php?id='.$idPersonne.'&idc='.$idContrat.'&typass='.$sTypass.'&sin='.$iSinistre);
	
	echo $oPaj->toString();
	}
	
	include_once PATH_INCLUDE.'inc_pied_page.php';
?>